<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文章添加--layui后台管理模板</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../../js/layui/css/layui.css" media="all" />
<script type="text/javascript" src="../../release/wangEditor.js"></script>
<script src="../../js/layui/layui.js"></script>
<link rel="stylesheet" href="../../css/font_eolqem241z66flxr.css"
	media="all" />
<style type="text/css">
.layui-form-item {
	margin-top: 30px;
}
</style>
</head>
<body class="childrenBody">
	<form class="layui-form" style="width: 80%;" id="Form"
		lay-filter="designerForm">
		<input type="hidden" name="id" />
		<div class="layui-form-item">
			<label class="layui-form-label">公司名称</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input linksName"
					lay-verify="required" placeholder="请输入名称" name="name">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司LOGO</label>
			<div class="layui-input-inline">
				<img id="imgFace" style="width: 120px" /><span> 点击更换</span><br />
				<input type="hidden" name="img" id="picName" value=""
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司文化</label>
			<div class="layui-input-block">
				<div id="culture1"></div>
				<textarea type="text" class="layui-textarea  linksUrl"
					lay-verify="required" placeholder="请输入" style="display: none;"
					name="Culture" id="culture2"></textarea>
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">公司简介</label>
			<div class="layui-input-block">
				<div id="simIntro1"></div>
				<textarea type="text" class="layui-textarea linksUrl"
					lay-verify="required" placeholder="请输入" style="display: none;"
					name="SimIntro" id="simIntro2"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司详情</label>
			<div class="layui-input-block">
				<div id="deiIntro1"></div>
				<textarea type="text" class="layui-textarea linksUrl"
					lay-verify="required" placeholder="请输入" name="DeiIntro"
					style="display: none;" id="deiIntro2"></textarea>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司邮箱</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input linksName" lay-verify="email"
					placeholder="请输入名称" name="email">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司电话</label>
			<div class="layui-input-inline">
				<input type="text" class="layui-input linksName"
					lay-verify="required" placeholder="请输入名称" name="phone">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">公司地址</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input linksUrl"
					lay-verify="required" placeholder="请输入" name="Address">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="addDesigner"
					id="submit">立即提交</button>

			</div>
		</div>
	</form>
	<script type="text/javascript">
		layui
				.use(
						[ 'upload', 'layer', 'form' ],
						function() {
							var upload = layui.upload, $ = layui.$, form = layui.form, layer = layui.layer;
						
							
								 $.post('../../../ComparyServlet?reqName=selectComparyAll',
												function(res){
									var data=res.data[0];
									
									var E = window.wangEditor;
						            var editor = new E('#culture1');
						            var editor2 = new E('#simIntro1');
						            var editor3 = new E('#deiIntro1');
						            editor.customConfig.onchange = function(html) {
										$("#culture2").val(html)
									}
						            editor2.customConfig.onchange = function(html) {
										$("#simIntro2").val(html)
									}
						            editor3.customConfig.onchange = function(html) {
										$("#deiIntro2").val(html)
									}
									editor.create()
									editor2.create()
									editor3.create()
									 $("#culture2").val(editor.txt.html())
									 editor.txt.html(data.cCulture)
									 $("#simIntro2").val(editor2.txt.html())
									 editor2.txt.html(data.cSimpIntro)
									 $("#deiIntro2").val(editor3.txt.html())
									 editor3.txt.html(data.cDeiIntro)
									 form.val("designerForm",{
											"img":data.cLogo,
											"name":data.cName,
											"Culture":data.cCulture,
											"SimIntro":data.cSimpIntro,
											"DeiIntro":data.cDeiIntro,
											"email":data.cEmail,
											"phone":data.cPhone,
											"Address":data.cAddress
										});
										$("#imgFace").attr("src",
												"../../../images/" + data.cLogo);
								}, "json");
    
							var uploadInst = upload.render({
								elem : '#imgFace'
								,
								url : '../../../AdminServlet?reqName=upload',
								acceptMime : 'image/*',
								done : function(res) {
									if (res) {
										
										$("#imgFace")
												.attr(
														"src",
														"../../../images/"
																+ res.remark);
									
										$("#picName").val(res.remark);
										layer.msg('新图片上传成功', {
											icon : 6,
											time : 1500
										});
									}
								},
								error : function() {
									layer.msg("图片上传失败");
								}
							});

							form.on('submit(addDesigner)',
											function(data) {
												$.post('../../../ComparyServlet?reqName=updateCompary',
																$("#Form").serialize(),
																function(res) {
																	if (res) {
																		var index = top.layer
																				.msg(
																						'数据提交中，请稍候',
																						{
																							icon : 16,
																							time : false,
																							shade : 0.8
																						});
																		setTimeout(
																				function() {
																					top.layer
																							.close(index);
																					top.layer
																							.msg("信息编辑成功！");
																					},
																				1000);
																	} else {
																		var index = top.layer
																				.msg(
																						'数据提交中，请稍候',
																						{
																							icon : 16,
																							time : false,
																							shade : 0.8
																						});
																		setTimeout(
																				function() {
																					top.layer
																							.close(index);
																					top.layer
																							.msg("设计师编辑失败！");

																				},
																				1000);
																	}
																}, "text")
												return false;
											})
						});
	</script>

</body>
</html>